package com.example.demo.service.impl;

import com.example.demo.dao.WorkOrderDao;
import com.example.demo.model.req.WoWorkTrackingAdviceReq;
import com.example.demo.model.req.WoWorkTrackingGoodReq;
import com.example.demo.model.req.WoWorkTrackingSaveReq;
import com.example.demo.pojo.WorkOrderDO;
import com.example.demo.service.WorkOrderService;
import com.example.demo.utils.TinyUUIDGenerate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Calendar;
import java.util.List;
@Service
public class WorkOrderServiceImpl implements WorkOrderService {
    @Resource
    WorkOrderDao workOrderDao;
    @Override
    public void reportProgress(WoWorkTrackingSaveReq workTrackingSaveReq) {
        WorkOrderDO  woWorkTrackingDTO = workTrackingSaveReq.reqToDto(workTrackingSaveReq);
        woWorkTrackingDTO.setTrackingTime(Calendar.getInstance().getTime());
        woWorkTrackingDTO.setCreateTime(Calendar.getInstance().getTime());
        woWorkTrackingDTO.setCreateBy("");
        woWorkTrackingDTO.setUpdateBy("");
        woWorkTrackingDTO.setTrackingId(TinyUUIDGenerate.generate());
        woWorkTrackingDTO.setIsDelete("0");
        woWorkTrackingDTO.setKind("维修");
        workOrderDao.insert(woWorkTrackingDTO);
    }

    @Override
    public void repostAdviceProgress(WoWorkTrackingAdviceReq woWorkTrackingAdviceReq) {
        WorkOrderDO woWorkTrackingDTO = woWorkTrackingAdviceReq.reqToDto(woWorkTrackingAdviceReq);
        woWorkTrackingDTO.setTrackingTime(Calendar.getInstance().getTime());
        woWorkTrackingDTO.setCreateTime(Calendar.getInstance().getTime());
        woWorkTrackingDTO.setCreateBy("");
        woWorkTrackingDTO.setUpdateBy("");
        woWorkTrackingDTO.setTrackingId(TinyUUIDGenerate.generate());
        woWorkTrackingDTO.setIsDelete("0");
        woWorkTrackingDTO.setKind("建议");
        woWorkTrackingDTO.setSuggestReason(woWorkTrackingAdviceReq.getSuggestReason());
        woWorkTrackingDTO.setIsAccept(woWorkTrackingAdviceReq.getIsAccept());
        workOrderDao.insert(woWorkTrackingDTO);
    }

    @Override
    public void repostPraiseProgress(WoWorkTrackingGoodReq woWorkTrackingGoodReq) {
        WorkOrderDO woWorkTrackingDTO = woWorkTrackingGoodReq.reqToDto(woWorkTrackingGoodReq);
        woWorkTrackingDTO.setTrackingTime(Calendar.getInstance().getTime());
        woWorkTrackingDTO.setCreateTime(Calendar.getInstance().getTime());
        woWorkTrackingDTO.setCreateBy("");
        woWorkTrackingDTO.setUpdateBy("");
        woWorkTrackingDTO.setTrackingId(TinyUUIDGenerate.generate());
        woWorkTrackingDTO.setIsDelete("0");

        workOrderDao.insert(woWorkTrackingDTO);
    }

    @Override
    public List<WorkOrderDO> list() {
        return null;
    }
}
